package com.example.controller;

import com.example.pojo.Admin;
import com.example.pojo.Announce;
import com.example.pojo.Help;
import com.example.pojo.User;
import com.example.service.AdminService;
import com.example.service.impl.AdminServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class AdminController {
    @Resource(name = "adminService")
    public AdminService adminService;

    @RequestMapping("/admin/login")
    @ResponseBody
    public Admin login(String username,String password) {
        return adminService.login(username,password);
    }

    @RequestMapping("/admin/topicdata")
    @ResponseBody
    public Map<String,Object> getTopicData() {
        return adminService.getTopicData();
    }

    @RequestMapping("/admin/typecount")
    @ResponseBody
    public Map<String,Object> getTypeCount() {
        return adminService.getTypeCount();
    }

    @RequestMapping("/admin/userlist")
    @ResponseBody
    public List<Map<String,Object>> getUserList() {
        return adminService.getUserList();
    }

    @RequestMapping("/admin/adduser")
    @ResponseBody
    public Integer addUser(String username,String password,String nickname,String name,String sex,String avatar,
                           String phone,String idNumber,String enterYear,String className,String subject,String email) {
        return adminService.addUser(username, password, nickname, name, sex, avatar, phone, idNumber, enterYear,
                className, subject, email);
    }
    @RequestMapping("/admin/topiclist")
    @ResponseBody
    public List<Map<String,Object>> getTopicList() {
        return adminService.getTopicList();
    }

    @RequestMapping("/admin/announcelist")
    @ResponseBody
    public List<Announce> getAnnounceList() {
        return adminService.getAnnounceList();
    }

    @RequestMapping("/admin/helplist")
    @ResponseBody
    public List<Help> getHelpList() {
        return adminService.getHelpList();
    }

    @RequestMapping("/admin/addannounce")
    @ResponseBody
    public Integer addAnnounce(Integer aId,String avatar,String title,String content) {
        return adminService.addAnnounce(aId,avatar,title,content);
    }

    @RequestMapping("/admin/addhelp")
    @ResponseBody
    public Integer addHelp(Integer aId,String avatar,String title,String content) {
        return adminService.addHelp(aId,avatar,title,content);
    }

    @RequestMapping("/admin/deletetopic")
    @ResponseBody
    public Integer deleteTopic(Integer tId) {
        return adminService.deleteTopic(tId);
    }

    @RequestMapping("/admin/checktopic")
    @ResponseBody
    public Integer checkTopic(Integer tId,String checkStatus) {
        return adminService.checkTopic(tId,checkStatus);
    }
}
